﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.IO;

namespace TestRunner 
{
    public class  NUnitFolderNameValidationRule: ValidationRule 
    {
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            string path = value as string;
            if(String.IsNullOrWhiteSpace(path)) return new ValidationResult(false, "Not a string");

            if(!Directory.Exists(path)) return new ValidationResult(false, "Not a valid directory");

            var files = Directory.GetFiles(path, "nunit-console.exe");
            if (files.Length == 0) return new ValidationResult(false, "Not a NUnit directory");

            return ValidationResult.ValidResult;
        }
    }
}
